<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>图文作业消息</title>
    <?php require 'templates/common/head.html'; ?>
    <style>
        .in_1{ height: 30px; width: 120px;}
        .in_2{ height: 30px; width: 300px;}
    </style>
</head>
<body>
<div class="container-fluid">
    <?php require 'templates/common/nav.html'; ?>
    <div class="panel panel-primary">
        <div class="panel-heading text-center">
            <h3 class="panel-title">图文作业消息</h3>
        </div>
        <div class="panel-body" style="text-align:center">
            <div class="panel-heading text-right">
                <a href="index.php?m=news&a=edit" type="button" class="btn btn-primary">添加消息</a>
            </div>
            <div class="panel-heading text-right">
                <input type="text" id="phone" placeholder="手机号" class="in_1">
                <input type="text" id="oid" placeholder="openID" class="in_2">
            </div>
            <div class="panel-group"  id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                    <div class="panel-heading" style="background-color:#d5d5d5">
                        <div class="row" >
                            <div class="col-xs-1 col-sm-1">ID</div>
                            <div class="col-xs-3 col-sm-3">标题</div>
                            <div class="col-xs-3 col-sm-3">对象筛选</div>
                            <div class="col-xs-1 col-sm-1">添加时间</div>
                            <div class="col-xs-3 col-sm-3" style="text-align:center">操作</div>
                        </div>
                    </div>
                </div>
                <?php foreach($list as $k=>$v):?>
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="row" >
                            <div class="col-xs-1 col-sm-1"><?=$v['id']?></div>
                            <div class="col-xs-3 col-sm-3"><?=$v['pt_title']?></div>
                            <div class="col-xs-3 col-sm-3"><?=$v['note']?></div>
                            <div class="col-xs-1 col-sm-1"><?=$v['createTime']?></div>
                            <div class="col-xs-3 col-sm-3" style="text-align:center">
                                <a href="<?=$this->url('news', 'edit', array('id'=> $v['id']))?>"class="btn btn-primary btn-xs">编辑</a>
                                <button onclick="disabled=true;tuisong('<?=$v['id']?>')" class="btn btn-primary btn-xs">推送</button>
                            </div>

                        </div>
                    </div>
                </div>
                <?php  endforeach;?>
            </div>
        </div>
    </div>
</div>
<?php require 'templates/common/foot.html'; ?>
<script language="JavaScript">
    function tuisong(id){
        var oid = $("#oid").val();
        var phone = $("#phone").val();
        if(oid) {
             res = confirm("您确定给openId:’"+oid+"’推送消息吗?");
        } else if(phone) {
            res = confirm("您确定给手机号:’"+phone+"’推送消息吗?");
        } else {
             res = confirm("您确定给指定的用户群发消息吗？");
        }
        if(res) {
            $.post('index.php?m=news&a=send',{'id':id,'oid':oid, 'phone':phone},function(data){
                var res= eval('(' + data + ')');
                console.log(res);
                //alert(res.message);
                //location.reload();
            });
            alert("触发成功");
        }
    }
</script>
</body>
</html>